package com.acwing.partition21;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/5/10 9:02
 */
public class AC2040礼物 {

    private static final int N = 1010;
    private static int[][] gift = new int[N][2];
    private static int n, m;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt(); m = nextInt();
        for (int i = 1; i <= n; i++) {
            gift[i][0] = nextInt();
            gift[i][1] = nextInt();
        }
        Arrays.sort(gift, 1, n + 1, (o1, o2) -> Integer.compare(o1[0] / 2 + o1[1], o2[0] / 2 + o2[1]));
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int cost = 0, cnt = 0;
            for (int j = 1; j <= n; j++) {
                if (i == j) cost += gift[i][0] / 2 + gift[i][1];
                else cost += gift[j][0] + gift[j][1];
                cnt++;
                if (cost <= m) ans = Math.max(ans, cnt);
                else break;
            }
        }
        writer.println(ans);
        writer.flush();
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
